<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:fragment="headerFragment(title,active)">
    <meta charset="utf-8"/>
     <title>管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta content="Coderthemes" name="author"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <link rel="shortcut icon" th:href="@{/admin/images/favicon.png}"/>
    <link th:href="@{//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css}" rel="stylesheet"/>
    <link th:href="@{/admin/css/style.min.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{//cdn.bootcss.com/limonte-sweetalert2/6.4.1/sweetalert2.min.css}" rel="stylesheet"/>
    <style type="text/css">
		.table th, .table td { 
		text-align: center;
		vertical-align: middle!important;
		}
    </style>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
    <script th:src="@{//cdn.bootcss.com/jquery/2.2.3/jquery.min.js}"></script>
	<script th:src="@{//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js}"></script>
	<script th:src="@{//cdn.bootcss.com/limonte-sweetalert2/6.4.1/sweetalert2.min.js}"></script>
	<script th:src="@{/admin/js/jquery.app.js}"></script>
	<script th:src="@{/plugins/base.js}"></script>
	<script type="text/javascript" th:inline="javascript">
	   /*<![CDATA[*/
	   var  ctxPath = /*[[@{/}]]*/ '';
	   /*]]>*/
	   if(ctxPath=='/'){
		   ctxPath='';
	   }
	   
      var tale = new $.tale();//弹框
        function showModal(){
            $("#pwdModal").modal({
                backdrop:'static'
            });
        }

        function closeModal(){
            $("#pwdModal").modal('hide');
            $("#pwd-form")[0].reset();
        }

        function validate(){
            var oldPass = $("#oldPassword").val();
            if(oldPass == ''){
				$("#oldPassword").focus();
                tale.alertError('请输入旧密码');
                return false;
            }
            var newPass = $("#newPassword").val();
            if(newPass == ''){
                $("#newPassword").focus();
                tale.alertError('请输入新密码');
                return false;
            }
            var rePass = $("#rePassword").val();
            if(rePass == ''){
                $("#rePassword").focus();
                tale.alertError('请再输入一次新密码');
                return false;
            }
            if(rePass != newPass){
                $("#rePassword").focus();
                tale.alertError('两次输入密码不一致，请重新输入');
                return false;
            }

            return true;
        }

        function pwdForm(){
            if(validate()){
                var oldPass = $("#oldPassword").val();
                var newPass = $("#newPassword").val();
                var rePass = $("#rePassword").val();
                var userPass ={oldPassword:oldPass,newPassword:newPass,rePassword:rePass};
                $.ajax({
                    url: ctxPath+"/user/modifyPass",
                    type: 'POST',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify(userPass),
                    success: function (d) {
                        var success = d.success;
                        if (success) {
                            alert("修改成功，请重新登录");
                            window.location = ctxPath+"/logout";

                        } else {
                            alert(d.message);
                        }
                    }
                });
            }

        }
    </script>
</head>
<div th:fragment="header-body">
<div class="topbar">
    <div class="topbar-left">
        <div class="text-center p-t-10" style="margin: 0 auto;">
<!--             <div class="pull-left" style="padding-left: 10px;"> -->
<!--                 <a th:href="@{/admin/index}"> -->
<!--                     <img th:src="@{/admin/images/logo.png}" width="50" height="50"/> -->
<!--                 </a> -->
<!--             </div> -->
            <div class="pull-left" style="padding-left: 10px;">
                <span style="font-size: 28px; color: #2f353f; line-height: 50px;">江陵县住建局</span>
            </div>
        </div>
    </div>
    <div class="navbar navbar-default" role="navigation">
        <div class="container">
            <div class="">
                <div class="pull-left">
                    <button type="button" class="button-menu-mobile open-left">
                        <i class="fa fa-bars"></i>
                    </button>
                    <span class="clearfix"></span>
                </div>

                <ul class="nav navbar-nav navbar-right pull-right">
                    <li class="dropdown">
                        <a  class="dropdown-toggle profile" data-toggle="dropdown" aria-expanded="true" style="cursor: pointer;"><img  alt="user-img" class="img-circle" style="height: 30px;" th:src="${#httpServletRequest.getContextPath()+session.login_user_info.headImage}"/><span th:text="${session.login_user_info.nickname}"></span> </a>
                        <ul class="dropdown-menu">
<!--                             <li><a ><i class="fa fa-sun-o"></i>个人设置</a></li> -->
                            <li><a th:href="@{/logout}"><i class="fa fa-sign-out"></i> 注销</a></li>
                            <li><a onclick="showModal()"><i class="fa fa-sign-out"></i> 修改密码</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div class="left side-menu">
    <div class="sidebar-inner slimscrollleft">
        <div id="sidebar-menu">
            <ul>
                <li th:class="${active}=='agency'?'active':''" shiro:hasPermission="/agency/index">
                    <a th:href="@{/agency/index}"
                       th:class="${active}=='agency'?'waves-effect active':'waves-effect'"><i
                            class="fa fa-list" aria-hidden="true"></i><span> 机构 </span></a>
                </li>
                <li th:class="${active}=='supervise'?'active':''" shiro:hasPermission="/supervise/index">
                    <a th:href="@{/supervise/index}" th:class="${active}=='supervise'?'waves-effect active':'waves-effect'"><i
                            class="fa fa-file-text" aria-hidden="true"></i><span> 督办 </span></a>
                </li>
                <li th:class="${active}=='party'?'active':''"  shiro:hasPermission="/party/index">
                    <a th:href="@{/party/index}" th:class="${active}=='party'?'waves-effect active':'waves-effect'"><i
                            class="fa fa-file-text" aria-hidden="true"></i><span> 党建 </span></a>
                </li>
                <li th:class="${active}=='visit'?'active':''" shiro:hasPermission="/visit/index">
                    <a th:href="@{/visit/index}"
                       th:class="${active}=='visit'?'waves-effect active':'waves-effect'"><i
                            class="fa fa-comments" aria-hidden="true"></i><span> 信访 </span></a>
                </li>
                <li th:class="${active}=='set'?'active':''" shiro:hasPermission="/set/index">
                    <a th:href="@{/set/index}"
                       th:class="${active}=='set'?'waves-effect active':'waves-effect'"><i
                            class="fa fa-gear" aria-hidden="true"></i><span> 系统设置 </span></a>
                </li>
            </ul>
            <div class="clearfix"></div>
        </div>
        <div class="clearfix"></div>
    </div>
</div>

    <!-- Modal -->
    <div class="modal fade" id="pwdModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="content">
                        <div class="container">
                            <div class="row">
                                <div class="col-md-12">
                                    <form class="form-horizontal" role="form" id="pwd-form" onsubmit="return validate();">

                                        <div class="form-group"  >
                                            <label class="col-sm-2 control-label">旧密码</label>
                                            <div class="col-md-9">
                                                <input type="password" class="form-control" name="oldPassword" id="oldPassword" placeholder="旧密码"
                                                       required="required" aria-required="true"/>
                                            </div>
                                        </div>
                                        <div class="form-group"  >
                                            <label class="col-sm-2 control-label">新密码</label>
                                            <div class="col-md-9">
                                                <input type="password" class="form-control" name="newPassword" id="newPassword" placeholder="新密码"
                                                       required="required" aria-required="true"/>
                                            </div>
                                        </div>
                                        <div class="form-group" >
                                            <label class="col-sm-2 control-label">确认密码</label>
                                            <div class="col-md-9">
                                                <input type="password" class="form-control" name="rePassword" id="rePassword" placeholder="确认密码"
                                                       required="required" aria-required="true"/>
                                            </div>
                                        </div>
                                        <div class="clearfix"></div>
                                        <div class="clearfix"></div>
                                        <div class="text-center">
                                            <button type="button" class="btn btn-primary waves-effect waves-light"
                                                    onclick="closeModal()">
                                                关闭
                                            </button>
                                            <button type="button" class="btn btn-primary waves-effect waves-light"
                                                    onclick="pwdForm();">
                                                保存
                                            </button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</html>